<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');?>
<script type="text/javascript" src="http://cpc.admicro.vn/vcm/ckeditor/ckeditor.js"></script>
<script src="http://cpc.admicro.vn/vcm/ckeditor/_samples/sample.js" type="text/javascript"></script>
<link href="http://cpc.admicro.vn/vcm/ckeditor/_samples/sample.css" rel="stylesheet" type="text/css" />
<div class="middle padtop10 myclear">
	<div class="page-content">
		
		<!-- bread crumb -->
		<p id="bread-crumb">
			<a href="<?php echo base_url();?>">
				<?php echo $lang['home']?>
			</a>
			<?php echo $lang['banner_warring']?>
		</p>
		<!-- end bread crumb -->
		<h3>
			<?php echo $lang['banner_warring']?>
		</h3>
		<br style="clear:both;" />
		<table class="tbl-list" width="100%" border="1">
			<tr>
				<td width="4%" class="td-label" style="text-align:center">
					<b>#</b>
				</td>
				<td class="td-label" width="14%">
					<b><?php echo $lang['campaign'];?></b>
				</td>
				<td width="25%" class="td-label">
					<b><?php echo $lang['banner'];?></b>
				</td>
				<td class="td-label" width="25%">
					<b><?php echo $lang['target'];?></b>
				</td>
				<td class="td-label">
					<b><?php echo $lang['warring'];?></b>
				</td>
				<td class="td-label" style="text-align:center" width="5%">&nbsp;</td>
			</tr>
			<?php
            $i = 0; $currID = 0;
			foreach ($items as $item){;
			?>
			<tr>
				<?php if($currID != $item->campaignid) { $i++;?>
				<td style="text-align:center" <?php if($colspan[$item->campaignid] > 1) echo 'rowspan="'.$colspan[$item->campaignid].'"';?>>
					<?php echo $i;?>
				</td>
                <td <?php if($colspan[$item->campaignid] > 1) echo 'rowspan="'.$colspan[$item->campaignid].'"';?>>
					<a href="<?php echo site_url('campaigndetail/index/?campaignid='.$item->campaignid.'&fromdate='.date('Y-m-d').'&todate='.date('Y-m-d'));?>" target="_blank">
						<?php echo $item->campaignname;?>
                    </a>
                    <p style="margin-top:5px">
                    	<?php echo '<b>'.$lang['budget'].'</b>: '.number_format($item->budget);?> (click)
                    </p>
                    <p>
                    	<?php echo '<b>'.$lang['click'].'</b>: '.number_format($item->click);?>
                    </p>
                    <p>
                    	<?php echo '<b>'.$lang['realclick'].'</b>: '.number_format($item->realclick);?>
                    </p>
                    <p>
                    	<?php echo '<b>'.$lang['view'].'</b>: '.number_format($item->realview);?>
                    </p>
                    <p>
                    	<?php echo '<b>'.$lang['ctr'].'</b>: '.$item->CTR;?>
                    </p>
                    <p>
                    	<?php echo '<b>'.$lang['percent'].'</b>: '.$item->percencomplete;?>%
                    </p>
				</td>
                <?php }?>
				<td style="text-align:center">
					<table width="100%" border="0" class="banner-format">
						<tr>
							<td colspan="2">
                            	<b><?php echo $item->bannername;?></b>
                                <p style="color:#999"><?php echo $this->mycommon->getDomainFromUrl($item->url);?></p>
                            </td>
						</tr>
                        <tr>
                        	<td width="90">
                            	<img src="<?php echo $this->mycommon->getBannerImagPath('','',$item->filename,strtotime($item->createtime));?>" border="0" class="ibanner" />
                            </td>
                            <td>
                            	<?php echo $item->bannertext;?>
                            </td>
                        </tr>
					</table>
				</td>
				<td>
					<p><?php echo '<b>'.$lang['location'].'</b>: '.$this->mycommon->checkLocation($item->locationAd,$arrLocation);?></p>
					<p><?php echo '<b>'.$lang['list_site'].'</b>: '.str_replace(',',', ',$item->list_site);?></p>
				</td>
				<td>
					<div id="warring<?php echo $item->bannerid;?>">
						<?php echo $item->description;?>
					</div>
				</td>
				<td style="text-align:center;vertical-align:middle" width="8%">
					<a href="javascript:void(0);" onclick="addWarring(<?php echo $item->bannerid;?>,1);">
						<?php echo $lang['edit_warring'];?>
					</a>
				</td>
			</tr>
			<?php $currID = $item->campaignid; }?>
		</table>
	</div>
</div><br />
<div id="panel-popup" style="display:none">
	<div style="background:#fff; padding:20px; position:relative">
		<div class="pay-mess"></div>
		<table width="100%" style="border-spacing:5px">
			<tr>
				<td>
					<textarea cols="80" id="warring-text" name="warrings-text" rows="10"></textarea>
				</td>
			</tr>
			<tr>
				<td><br />
					<input type="hidden" name="bannerid" id="bannerid" value="" />
					<input type="button" onclick="$('#mask,#panel-popup').hide();" style="float:right;margin-left:10px" value="<?php echo $lang['close']?>">
					<input type="button" onclick="submitWarring();" style="float:right" value="<?php echo $lang['add']?>">
				</td>
			</tr>
		</table>
		<img id="loading-order" src="/images/ajaxLoading.gif" border="0" />
	</div>
</div>
<div id="mask"></div>
<script type="text/javascript">
CKEDITOR.replace( 'warring-text',
{
	skin : 'v2'
});
function addWarring(id)
{
	$('#bannerid').val(id);
	$('#panel-popup .pay-mess').html('');
	var cwarring = $('#warring'+id).html();
	//$('#warring-text').val(cwarring);
	$('#cke_warring-text iframe').contents().find('body').html(cwarring);
	payPopup('panel-popup');
}
function submitWarring()
{
	var id = $('#bannerid').val();
	var text = $('#cke_warring-text iframe').contents().find('body').html();
	$('#loading-order').fadeIn('fast');
	$.ajax({
		type: 'post',
		data: {id:id, text:text},
		url: '<?php echo site_url('bannerwarring/saveWarring');?>',
		success: function(data){
			$('#loading-order').fadeOut('fast');
			data = $.parseJSON(data);
			$('#panel-popup .pay-mess').html(data.mess);
			if(data.status == 1)
			{
				$('#warring'+id).html(text);
				setTimeout("$('#mask,#panel-popup').hide();", 3000);
			}
		}
	});
}
</script>